/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.kimstore.gui.sales;

import com.kimstore.bean.Item;
import com.kimstore.bean.Product;
import com.kimstore.factory.DaoFactory;
import com.kimstore.gui.repair.ViewItemForRepairController;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author Administrator
 */
public class SelectReplacementItemController {

    private List<Item> items;
    private SelectReplacementItemWindow selectReplacementItemWindow;
    private ViewItemForRepairController controller;

    public SelectReplacementItemController(ViewItemForRepairController controller) {
        this.controller = controller;
    }

    public void displayWindow() {
        this.items = DaoFactory.getInstance().getItemDao().getAllAvailableItems();

        selectReplacementItemWindow = new SelectReplacementItemWindow(this);
        selectReplacementItemWindow.populateTable(items);
        selectReplacementItemWindow.displayWindow();
    }

    public void fromWindow(String sku) {
        controller.createSelectReplacementItemControllerCallback(DaoFactory.getInstance().getItemDao().findBySerial(sku));
    }
}
